package com.ninth_group.constant;

/**
 * 天气信息代码
 */
public class WeatherCode {
    private static final int CLOUDY = 63001;         // 多云
    private static final int CLOUDY_NIGHT = 63002;   // 夜间多云
    private static final int FOG = 63003;            // 大雾
    private static final int HEAVY_RAIN = 63004;     // 大雨

    private static final int HEAVY_WIND = 63005;     // 大风
    private static final int LIGHT_RAIN = 63006;     // 小雨
    private static final int SANDSTORM = 63008;      // 沙尘暴

    private static final int SNOW = 63009;           // 大雪
    private static final int SNOWFLAKE = 63010;      // 小雪
    private static final int SUNNY = 63011;            // 晴

    private static final int CLOUDY_BECOMING_SUNNY = 63012;  // 多云转晴
    private static final int THUNDERSTORM = 63013;   // 雷雨
    private static final int WIND = 63014;           // 刮风

    /**
     * 根据天气名称获取对应的天气编码
     * @param weather 天气描述字符串
     * @return 匹配的天气编码，若无匹配则返回 -1
     */
    public static int getCodeByWeather(String weather) {
        if (weather == null) return -1;

        return switch (weather.trim()) {
            case "多云" -> CLOUDY;
            case "夜间多云" -> CLOUDY_NIGHT;
            case "大雾" -> FOG;
            case "大雨" -> HEAVY_RAIN;
            case "大风" -> HEAVY_WIND;
            case "小雨" -> LIGHT_RAIN;
            case "沙尘暴" -> SANDSTORM;
            case "大雪" -> SNOW;
            case "小雪" -> SNOWFLAKE;
            case "晴" -> SUNNY;
            case "多云转晴" -> CLOUDY_BECOMING_SUNNY;
            case "雷雨" -> THUNDERSTORM;
            case "刮风" -> WIND;
            default -> -1; // 未知天气类型
        };
    }
}


